<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right" style="padding-left: 10px;padding-bottom: 10px;font-size: 12px;">
            <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>挂号预约</el-breadcrumb-item>
            <el-breadcrumb-item>挂号管理</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
             <el-form :inline="true" :model="registration" class="demo-form-inline">
                 <!-- 预约状态 -->
                <el-form-item label="状态" label-width="70px">
                 <el-select v-model="registration.status" clearable placeholder="请选择">
                    <el-option
                    v-for="item in options"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value">
                    </el-option>
                </el-select>
                </el-form-item> 
                <!-- 科室名 -->
                <el-form-item label="科室" label-width="70px">
                    <el-input
                        placeholder="请输入科室名称"
                        v-model="registration.departmentName"
                        clearable>
                    </el-input>
                </el-form-item>
                <!-- 医生名 -->
                <el-form-item label="医生" label-width="70px">
                    <el-input
                        placeholder="请输入医生名称"
                        v-model="registration.doctorName"
                        clearable>
                    </el-input>
                </el-form-item>
                <!-- 挂号用户 -->
                <el-form-item label="患者" label-width="70px">
                    <el-input
                        placeholder="请输入患者名称"
                        v-model="registration.userName"
                        clearable>
                    </el-input>
                </el-form-item>
                 <el-form-item style="margin-left: 50px;">
                    <el-button icon="el-icon-refresh" @click="reset">重置</el-button>
                    <el-button type="primary" icon="el-icon-search" @click="getAllReg">查询</el-button>
                    <!-- <el-button type="success" icon="el-icon-plus" @click="show">添加</el-button>
                    <el-button type="warning" icon="el-icon-download">导出</el-button> -->
                </el-form-item>
             </el-form>
            <el-table
                ref="singleTable"
                :data="registrationList"
                
                
                style="width: 100%; margin-top: 30px">
                <el-table-column
                type="index"
                width="50">
                </el-table-column>
                <!-- 科室 -->
                <el-table-column
                property="departmentName"
                label="科室"
                width="120">
                <template slot-scope="scope">
                    <el-tag type="" closable v-text="scope.row.departmentName"></el-tag>
                </template>
                </el-table-column>
                <!-- 日期 -->
                <el-table-column
                property="date"
                label="挂号日期"
                width="120">
                <template slot-scope="scope">
                    <el-tag type="warning" closable v-text="scope.row.date"></el-tag>
                </template>
                </el-table-column>
                <el-table-column
                property="userName"
                label="姓名"
                width="120">
                </el-table-column>
                <!-- 年龄 -->
                <el-table-column
                property="age"
                label="年龄"
                width="100">
                </el-table-column>
                <!-- 医生 -->
                <el-table-column
                property="doctorName"
                label="医生"
                width="120">
                </el-table-column>
                <!-- 类型 -->
                 <el-table-column
                property="type"
                label="级别"
                width="100">
                <template slot-scope="scope">
                    <el-tag type="danger" effect="plain" v-if="scope.row.type==1">专家</el-tag>
                    <el-tag type="success" effect="plain" v-if="scope.row.type==0">普通</el-tag>     
                </template>
                </el-table-column>
                <!-- 费用 -->
                <el-table-column
                property="type"
                label="挂号费"
                width="100">
                <template slot-scope="scope">
                    <el-tag type="danger" effect="plain" v-if="scope.row.type==1">30元</el-tag>
                    <el-tag type="success" effect="plain" v-if="scope.row.type==0">18元</el-tag>
                </template>
                </el-table-column>
                <el-table-column
                property="date"
                label="问诊地点"
                width="150">
                <template slot-scope="scope">
                    <span ><i class="el-icon-location"></i>{{scope.row.place}}</span>
                </template>
                </el-table-column>
                <!-- 状态 -->
                <el-table-column
                fixed="right"
                property="status"
                label="状态"
                width="140">
                <template slot-scope="scope">
                    <el-tag type="warning" effect="dark" v-if="scope.row.status==0">正在预约中</el-tag>
                    <el-tag type="" effect="dark" v-if="scope.row.status==1">预约成功，待问诊</el-tag>
                    <el-tag type="success" effect="dark" v-if="scope.row.status==2">已问诊</el-tag>
                </template>
                </el-table-column>
            </el-table>
            <!-- 分页 -->
             <el-pagination
                style="padding-top:10px;"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="current"
                :page-sizes="[6, 10, 20, 30]"
                :page-size="size"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total">
             </el-pagination>    
        </el-card>

    </div>
</template>

<script>
import {getAll} from '../../api/users'
export default {
    name:'Patients',
    data() {
        return{
            registrationList:[],
            registration:{
                status:'',
                departmentName:'',
                userName:'',
                doctorName:'',
            },
            size:6,
            current:1,
            total:100,
            historyList:[],
            options:[{
            value: '0',
            label: '正在预约中'
            },{
            value: '1',
            label: '预约成功，待问诊'
            },{
            value: '2',
            label: '已问诊'
            },
             ]
            
        }
    },
    methods:{
         reset() {
        this.registration = {
                status:'',
                departmentName:'',
                userName:'',
                doctorName:'',
        }
    },
        async getAllReg() {
            const res = await getAll(this.registration,this.size,this.current)
            this.total = res.data.data.total;
            this.registrationList = res.data.data.registrationList;
            console.log(this.registrationList);
        },
         //当每页条数发生改变时
       handleSizeChange(val) {
        //console.log(`每页 ${val} 条`);
        this.size = val;
        //重新查询数据
        this.getAll();
      },
      //当前页码改变时
      handleCurrentChange(val) {
        //console.log(`当前页: ${val}`);
        this.current = val;
        this.getAll(); 
      },

    
    },
    created(){
        this.getAllReg();
    }
}
</script>

<style>

</style>